<?php
namespace Android\Model;

class NoticeModel extends BaseModel {


    public function getNoticeByWhere($where,$limit='') {

        empty($where) && $where='';
        $result = $this->field("id,teacher_id,title,addtime,thumb")->where($where)->limit($limit)->order('addtime desc')->select();
        return $result;

    }



    public function getNoticeById($id, $field = "*") {
        return $this->field($field)->find($id);
    }


    public function getNoticeDetail($id) {
        $notice = $this->table('__NOTICE__ notice, __TEACHER__ teacher')
                       ->field('notice.title, notice.content, notice.addtime, teacher.name AS teacher_name')
                       ->where("notice.id = {$id} AND notice.teacher_id = teacher.id")
                       ->find();
        return $notice;
    }

}